﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jayden.Dll.Core.Persistence;
using Jayden.Dll.Core.Persistence.Attributes;

namespace Jayden.Dll.Entities.Common
{
	[Table]
	public class InvoiceLine : ObjectBase, IComparable<InvoiceLine>
	{
		private long m_InvoiceId;
		private int m_OrderIndex;
		private string m_Label;
		private string m_Reference;
		private float m_Price;
		private float m_Amount;
		private Invoice m_Invoice;

		public InvoiceLine(UnitOfWork uow) : base(uow, 0) { }

		[Field(PrimaryKey = true, AutoIncrement = true)]
		public long InvoiceLineId { get { return (long)ObjectId[0]; } set { ObjectId[0] = value; } }
		[Field]
		public long InvoiceId { get { return m_InvoiceId; } set { m_InvoiceId = value; } }
		[Field]
		public int OrderIndex { get { return m_OrderIndex; } set { m_OrderIndex = value; } }
		[Field]
		public string Label { get { return m_Label; } set { m_Label = value; } }
		[Field]
		public string Reference { get { return m_Reference; } set { m_Reference = value; } }
		[Field]
		public float Price { get { return m_Price; } set { m_Price = value; } }
		[Field]
		public float Amount { get { return m_Amount; } set { m_Amount = value; } }

		public Invoice Invoice { get { return m_Invoice; } set { m_Invoice = value; } }

		public int CompareTo(InvoiceLine other)
		{
			return m_OrderIndex.CompareTo(other.m_OrderIndex);
		}
	}
}
